package MVC;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import GUIs.SimulatorGUI;
import LOG.Logger;
import THREADS.CustomerThreads;
import THREADS.ParcelThread;
import THREADS.WorkThread;

public class DataController {

	private DataObserver data_observer;
	private SimulatorGUI simulator;
	/**
	 * Constructor to create an object for observer controller with Observer and Simulator
	 * @param data_observer an object of Observer pattern
	 * @param simulator Frame of Simulator
	 */
	public DataController(DataObserver data_observer,SimulatorGUI simulator){
		this.data_observer = data_observer;
		this.simulator = simulator;
		this.simulator.addsetListener(new SetListener());
		
	}	

	/**
	 * ActionClass for UpdatePanel's update button
	 */
	public class SetListener implements ActionListener 
	{
		public void actionPerformed (ActionEvent e)
		{		
			data_observer.setSpeed(simulator.getTime());
			Logger.writeLog("Changes the speed of thread to " +simulator.getTime());
		}
	}
}